<?php
class Name
{
	//获取用户名字
	static function get_username($db, $uid){//数据库、uid
		$uid = intval($uid);
		
		$sql = 'select uid,username,name from admin_users where uid='.$uid;
		$rs = $db->query($sql)->getOne();
		if( $rs['name'] != '' ){
			return $rs['name'];
		}elseif( $rs['username'] != '' ){
			return $rs['username'];
		}else{
			return $uid;
		}
	}
	
	//获取栏目名称
	static function get_catename($db, $category_id){//数据库、category_id
		$category_id = intval($category_id);
		
		if( $category_id < 1 ){
			switch ($category_id){
				case 0:
					return '最新文章列表';
					break;
				case -1:
					return '文章回收站';
					break;
				case -2:
					return '推荐文章列表';
					break;
				case -3:
					return '模板管理页';
					break;
				default:
					return '';
			}
		}else{
			$sql = 'select id,title from categories where id='.$category_id;
			$rs = $db->query($sql)->getOne();
			if( $rs['id'] < 1 ){
				return '';
			}else{
				return $rs['title'];
			}
		}
	}
}